package memento;

import java.util.Date;

public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator("v1.0", "syx", System.currentTimeMillis());

        Caretaker caretaker = new Caretaker();

        System.out.println("保存版本v1.0");
        caretaker.add(originator.createMemento());
        System.out.println("当前版本：" + originator.toString());

        originator.setVersion("v1.1");
        originator.setCreateTime(System.currentTimeMillis());
        System.out.println("保存版本v1.1");
        caretaker.add(originator.createMemento());
        System.out.println("当前版本：" + originator.toString());

        System.out.println("回退版本至v1.0");
        originator.restoreMemento(caretaker.get(0));

        System.out.println("当前版本：" + originator.toString());

    }
}
